<?php

include_once '../ws/users_module.php';

$user = new UsersModule();

if ($_REQUEST['subscribe_user']){
	controllerSuscribeUser();
}



function controllerSuscribeUser() {
	$name = $_REQUEST['name'];
	$company = $_REQUEST['company'];
	$telephone = $_REQUEST['telephone'];
	$telephone2 = $_REQUEST['telephone2'];
	$email = $_REQUEST['email'];
	$message = $_REQUEST['message'];
	
	if (!$name || !$telephone || !$email){
		//campos vacios
		return;
	}
	
	if (is_numeric($telephone)) {
		//datos incorrectos
		return;
	}
	
	if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
		//La dirección de correo no es buena
		return;
	}
	
	$user->registerUserInformation($name, $company, $telephone, $telephone2, $email, $message);
}

?>